<!DOCTYPE html>
{% load i18n %}
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="shortcut icon" type="image/png" href="/static/favicon.ico"/>
    <link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
    {% include 'show/link.html'%}

    <!--- art template web -->
    <!-- ie compatible -->
    <script src="/static/lib/art-template/web-ie-compatible/es5-shim.min.js"></script>
    <script src="/static/lib/art-template/web-ie-compatible/es5-sham.min.js"></script>
    <script src="/static/lib/art-template/web-ie-compatible/json3.min.js"></script>
    <!-- ie compatible end -->
    <script src="/static/lib/art-template/template-web.js"></script>
    <!--- art template web end -->
    <link type="text/css" href="/static/lib/jquery-ui/css/custom-theme/jquery-ui-1.10.0.custom.css" rel="stylesheet"/>
    <!--
    <script src="/static/site/common_define.js"></script>
    -->
    {% include 'show/common_define.html' %}
    <script src="/static/site/common_func.js"></script>
    <title>{% trans '打款查询' %}</title>
    <style>
    </style>
    <script>
        {% if user.is_authenticated %}
        g_auth = true;
        {% endif %}

        $(document).ready(function() {
            //查询按钮
            $("#query_button").click(function()
            {
                on_withdraw_query();
            });
        })

        function on_withdraw_query(){
            if (!g_auth){
                return
            }
            $.post("{% url 'cs:admin_withdraw_query' %}",
            $("#withdraw_form").serialize(),
            function(data){
                console.log("get withdraw query info "  + JSON.stringify(data))
                console.log("get withdraw query info "  + data.length)
                var d1 = {
                    jsonobj: data,
                }
                var html = template("temp_withdraw", d1);
                document.getElementById("withdraw").innerHTML = html;
            })
        }
        function withdraw_update(id, status) {
            if (!g_auth){
                return
            }
            var key = "#msg_" +id
            var msg = $(key).val()
            console.log("get msg " + msg)

            $.post("{% url 'cs:admin_withdraw_update' %}",
            {msg:msg, id:id, status:status},
            function(data){
                //console.log("get withdraw query info "  + JSON.stringify(data))
                if (data['result'] == true)
                {
                    alert("提交成功")
                    var obj = $("#update_button_"+id);
                    obj.attr('disabled',true);
                    var obj = $("#update_button2_"+id);
                    obj.attr('disabled',true);
                }
                else{
                    alert("提交失败:" + data['msg'])
                }
            })
        }
    </script>
</head>
<body>

{% include 'show/top_bar.html' %}
<div class="main_body">
        <ol class="breadcrumb">
            <li><a href="{%url 'index'%}">{% trans '首页' %}</a></li>
            <li><a href="/cs/">{% trans '管理页面' %}</a></li>
        </ol>
    <div class="container">
        <br>
        <div class="panel panel-bm ">
            <div class="panel-heading">
                {% trans '提现查询' %}
            </div>
            <div class="panel-body">
                <form class="form-horizontal" id="withdraw_form" method="post" role="form">
                    <div class="col-xs-12 col-md-6">
                        <div class="form-group col-xs-12 col-md-12">
                            <div class="input-group">
                                <span class="input-group-addon green">{% trans '手机号码' %}</span>
                                <input type="text" class="form-control" name="phone" id="phone" value="">
                            </div>
                        </div>
                        <div class="form-group col-xs-12 col-md-12">
                            <div class="input-group">
                                <span class="input-group-addon green">{% trans '姓名' %}</span>
                                <input type="text" class="form-control" name="bank_account_name" id="bank_account_name">
                                <span class="input-group-addon green">{% trans '账户' %}</span>
                                <input type="text" class="form-control" name="bank_account" id="bank_account">
                            </div>
                        </div>
                        <div class="form-group col-xs-12 col-md-12">
                            <div class="input-group">
                                <span class="input-group-addon green">{% trans '开始时间(小时)' %}</span>
                                <input type="text" class="form-control" name="hour_begin" id="hour_begin">
                                <span class="input-group-addon green">{% trans '结束时间(小时)' %}</span>
                                <input type="text" class="form-control" name="hour_end" id="hour_end">
                            </div>
                        </div>
                        <div class="form-group col-xs-12 col-md-12">
                            <div class="input-group">
                                <span class="input-group-addon green">{% trans '状态(0未打款,1成功,2失败,3,已撤销,4处理中,5撤销成功)' %}</span>
                                <input type="text" class="form-control" name="status" id="status" value="0">
                            </div>
                        </div>
                        <div class="form-group col-xs-12 col-md-12">
                            <button type="button" id="query_button" class="btn btn-block btn-success">{% trans '查询' %}</button>
                        </div>
                    </div>
                </form>
            </div> <!-- pm body end-->
        </div>

        <div class="panel panel-bm ">
            <div class="panel-heading">
                {% trans '查询结果' %}
            </div>
            <div class="panel-body">
                <div id="withdraw"></div>
            </div> <!-- pm body end-->
        </div>
    </div>
</div>
</div>
{% include 'show/footer.html' %}
</body>
</html>
<script id="temp_withdraw" type="text/html">
    <table class="table table-hover ">
        <thead>
        <th>{% trans 'id' %}</th>
        <th>{% trans '用户ID' %}</th>
        <th>{% trans '原因' %}</th>
        <th>{% trans '失败操作' %}</th>
        <th>{% trans '时间' %}</th>
        <th>{% trans '姓名' %}</th>
        <th>{% trans '银行' %}</th>
        <th>{% trans '账户' %}</th>
        <th>{% trans '省' %}</th>
        <th>{% trans '市' %}</th>
        <th>{% trans '分行' %}</th>
        <th>{% trans '金额' %}</th>
        <th>{% trans '状态' %}</th>
        <th>{% trans '确认操作' %}</th>
        <th>{% trans '成功操作' %}</th>
        </thead>
        <tbody class="red">
        <% for(i = 0; i < jsonobj.length; i ++ ){ %>
        <% var info = jsonobj[i] %>
        <% var create_time = $imports.dateFormat(info.create_time) %>
        <% var status_cn = "{% trans '未打款' %}"%>
        <% if (info.status == 1){%>
            <% status_cn = "{% trans '成功' %}"%>
        <% }%>
        <% if (info.status == 2){%>
            <% status_cn = "{% trans '失败' %}"%>
        <% }%>
        <tr>
            <form class="form-horizontal" id="withdraw_form_<%=info.id%>" method="post" role="form">
                <td><%=info.id%></td>
                <td><%=info.userid%></td>
                <td>
                    <div class="form-group ">
                        <div class="input-group">
                            <input id="msg_<%=info.id%>" type="text" class="form-control" value="<%=info.admin_msg%>">
                        </div>
                    </div>
                </td>
                <td>
                    <div class="form-group ">
                        <% if (info.status != 1) {%>
                        <button type="button" id="update_button_<%=info.id%>" class="btn btn-danger" onclick="withdraw_update(<%=info.id%>, 2)">{% trans '更新为失败' %}</button>
                        <% }%>
                    </div>
                </td>
                <td><%=create_time%></td>
                <td><%=info.bank_account_name%></td>
                <td><%=info.bank%></td>
                <td><%=info.bank_account%></td>
                <td><%=info.province%></td>
                <td><%=info.city%></td>
                <td><%=info.bank_branch%></td>
                <td><%=info.amount%></td>
                <td><%=status_cn%></td>
                <td>
                    <div class="form-group ">
                        <% if (info.status != 1) { %>
                        <button type="button" id="update_button3_<%=info.id%>" class="btn btn-success" onclick="withdraw_update(<%=info.id%>, 4)">{% trans '处理中 打款前先点这个' %}</button>
                        <% } %>
                    </div>
                </td>
                <td>
                    <div class="form-group ">
                        <% if (info.status != 1) { %>
                        <button type="button" id="update_button2_<%=info.id%>" class="btn btn-success" onclick="withdraw_update(<%=info.id%>, 1)">{% trans '更新为成功' %}</button>
                        <% } %>
                    </div>
                </td>
            </form>
        </tr>
        <% } %>
        </tbody>
    </table>
</script>
